boot: Drop ostree-finalize-staged.path
authorJonathan Lebon <jonathan@jlebon.com>
Fri, 7 Mar 2025 21:49:27 +0000 (16:49 -0500)
committerJonathan Lebon <jonathan@jlebon.com>
Fri, 7 Mar 2025 22:11:44 +0000 (17:11 -0500)
This effectively reverts ac1a919f ("boot: Add
ostree-finalize-staged.path").

A bug came in on the OCP side that demonstrates that the way things are
setup right now is racy. If a reboot is triggered quickly after staging
a deployment, the whole pipeline of:

- ostree-finalize-staged.path, which triggers
- ostree-finalize-staged.service, which triggers
- ostree-finalize-staged-hold.service,

may not fully have happened before systemd isolates to `reboot.target`
which will want to kill all pending jobs.

Just directly starting the systemd unit is less elegant but much more
explicit and gets rid of any possible race because it's directly part of
the staging operation.

Fixes: https://issues.redhat.com/browse/OCPBUGS-51150
Makefile-boot.am
src/boot/ostree-finalize-staged.path [deleted file]
src/libostree/ostree-impl-system-generator.c
src/libostree/ostree-sysroot-deploy.c
tests/kolainst/destructive/staged-deploy.sh

index c07b6b8123296528b67cb4c97d681399ce28307a..7b7cb892e25aacb512a898ad32ae350acc73ae96 100644 (file)
@@ -40,7 +40,6 @@ systemdsystemunit_DATA = src/boot/ostree-prepare-root.service \
        src/boot/ostree-remount.service \
        src/boot/ostree-boot-complete.service \
        src/boot/ostree-finalize-staged.service \
-       src/boot/ostree-finalize-staged.path \
        src/boot/ostree-finalize-staged-hold.service \
        src/boot/ostree-state-overlay@.service \
        $(NULL)
@@ -69,7 +68,6 @@ EXTRA_DIST += src/boot/dracut/module-setup.sh \
        src/boot/mkinitcpio \
        src/boot/ostree-boot-complete.service \
        src/boot/ostree-prepare-root.service \
-       src/boot/ostree-finalize-staged.path \
        src/boot/ostree-remount.service \
        src/boot/ostree-finalize-staged.service \
        src/boot/ostree-finalize-staged-hold.service \
diff --git a/src/boot/ostree-finalize-staged.path b/src/boot/ostree-finalize-staged.path
deleted file mode 100644 (file)
index 43ef0ca..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2018 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <https://www.gnu.org/licenses/>.
-
-# For some implementation discussion, see:
-# https://lists.freedesktop.org/archives/systemd-devel/2018-March/040557.html
-[Unit]
-Description=OSTree Monitor Staged Deployment
-Documentation=man:ostree(1)
-
-[Path]
-PathExists=/run/ostree/staged-deployment
-
-[Install]
-WantedBy=multi-user.target
index 6968c7388480a4255453eed537450f3e83ad384e..4bf3fb522397f3d240e3f3b7ea40f13660043975 100644 (file)
@@ -111,10 +111,6 @@ require_internal_units (const char *normal_dir, const char *early_dir, const cha
 
   if (!glnx_shutil_mkdir_p_at (normal_dir_dfd, "multi-user.target.wants", 0755, cancellable, error))
     return FALSE;
-  if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-finalize-staged.path", normal_dir_dfd,
-                 "multi-user.target.wants/ostree-finalize-staged.path")
-      < 0)
-    return glnx_throw_errno_prefix (error, "symlinkat");
   if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-boot-complete.service", normal_dir_dfd,
                  "multi-user.target.wants/ostree-boot-complete.service")
       < 0)
index 2d8705d5c86c6a75383d041a02bcc4c85c3fc754..f722e754216b5873e012b90d2d757ae700c17387 100644 (file)
@@ -3788,6 +3788,15 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, const char *osname,
   if (booted_deployment == NULL)
     return glnx_prefix_error (error, "Cannot stage deployment");
 
+  const char *const systemctl_argv[]
+      = { "systemctl", "start", "ostree-finalize-staged.service", NULL };
+  int estatus;
+  if (!g_spawn_sync (NULL, (char **)systemctl_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL,
+                     NULL, &estatus, error))
+    return FALSE;
+  if (!g_spawn_check_exit_status (estatus, error))
+    return FALSE;
+
   g_autoptr (OstreeDeployment) deployment = NULL;
   if (!sysroot_initialize_deployment (self, osname, revision, origin, opts, &deployment,
                                       cancellable, error))
index 198814898fb73c58ac045030ecee4539390d5f01..a268a5ccfba7dea4b07b0912ae367b45cf33d1e1 100755 (executable)
@@ -12,7 +12,6 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
   sed -i -e 's,gpg-verify=true,gpg-verify=false,' /etc/ostree/remotes.d/*.conf
 
   # Test our generator
-  test -f /run/systemd/generator/multi-user.target.wants/ostree-finalize-staged.path
   test -f /run/systemd/generator/local-fs.target.requires/ostree-remount.service
 
   cat >/etc/systemd/system/sock-to-ignore.socket << 'EOF'
@@ -49,11 +48,8 @@ EOF
     ostree commit --no-bindings --parent="${commit}" -b staged-deploy -I --consume t
     newcommit=$(ostree rev-parse staged-deploy)
     orig_mtime=$(stat -c '%.Y' /sysroot/ostree/deploy)
-    systemctl show -p SubState ostree-finalize-staged.path | grep -q waiting
     systemctl show -p ActiveState ostree-finalize-staged.service | grep -q inactive
-    systemctl show -p TriggeredBy ostree-finalize-staged.service | grep -q path
     ostree admin deploy --stage staged-deploy
-    systemctl show -p SubState ostree-finalize-staged.path | grep running
     systemctl show -p ActiveState ostree-finalize-staged.service | grep active
     new_mtime=$(stat -c '%.Y' /sysroot/ostree/deploy)
     test "${orig_mtime}" != "${new_mtime}"